package lib.Dao;

import lib.Model.School;

import java.sql.*;
import java.util.ArrayList;
import java.util.List;


public class TokenDao {
    public String gettoken() throws SQLException{
        Statement stmt = null;
        Dbutil dbutil = new Dbutil();
        Connection con = null;
        ResultSet rs = null;
        String token = null;
        try{
            con = dbutil.getCon();
            stmt = con.createStatement();
            String sql = "select * from access_token";
            rs = stmt.executeQuery(sql);
            while(rs.next()) {
              token=rs.getString("token");

            }
            return token;
        }catch (Exception e) {
            e.printStackTrace();
        }
        return token;
    }


    public void settoken(String token) throws SQLException{
        Statement stmt = null;
        Dbutil dbutil = new Dbutil();
        Connection con = null;
        ResultSet rs = null;

        try{
            con = dbutil.getCon();
            stmt = con.createStatement();
            String sql = "update access_token set token="+"'"+token+"'"+" where id=1";
            stmt.executeUpdate(sql);

            return ;
        }catch (Exception e) {
            e.printStackTrace();
        }
        return ;
    }


}
